mui.init({
	beforeback:function(){
		plus.webview.getLaunchWebview().evalJS("mui.back();");
		return false;
	}
});
var merchant, apps;
mui.plusReady(function () {
	merchant = bexta.getStorage(MERCHANT);
	if( !merchant || merchant.uid && merchant.uid == "" ){
		mui.openWindow({
			id:'login',
			url:'login.html',
			show:{
				aniShow:'none'
			},
			waiting:{
				autoShow:false
			}
		});
		plus.navigator.closeSplashscreen();
		return ;
	}else{
		bexta.ajax(api.site, function(res){
			initEvent(res);
		}, {data:{uid:merchant.uid}});
		plus.navigator.closeSplashscreen();
	}
	
	
	var views = bexta.getWebview();
	views.setPullToRefresh({
		support:true,
		style:'default',
		contentdown:{
			caption:"下拉可刷新"
		},
		contentover:{
			caption:"释放开始刷新"
		},
		contentrefresh:{
			caption:"正在刷新"
		}
	}, function(){
		bexta.ajax(api.site, function(res){
			apps.counts = res;
			views.endPullToRefresh();
		}, {data:{uid:merchant.uid}});
	});
	
	
});
function initEvent(res){
	apps = new Vue({
		el:"#vueMain",
		data:{
			counts:res,
			mch:merchant
		},
		mounted:function(){
			document.querySelector('.loading').classList.add('loadRun');
		}
	})
}

window.addEventListener('updataMsg', function(){
	apps.mch = bexta.getStorage(MERCHANT);
});
